import {Space, Tag} from "antd";
import {ColumnsType} from "antd/es/table";
import {Link} from "react-router-dom";
import {SecurityMenu} from "type/entity/SecurityMenu";
import {columnDataIndex, columnOrder, columnRemark} from "./index";
import IconFont from "../util/icon-util";

const menuColumns: ColumnsType<SecurityMenu> = [
    columnDataIndex,
    {
        key: 'id',
        dataIndex: 'id',
        title: '菜单编号',
        width: 110,
        align: "center",
    },
    {
        key: 'label',
        dataIndex: 'label',
        title: '菜单标签',
        width: 100,
        align: "center"
    },
    {
        key: 'explain',
        dataIndex: 'explain',
        title: '菜单描述',
        width: 100,
        align: "center"
    },
    {
        key: 'path',
        dataIndex: 'path',
        title: '路径地址',
        width: 150,
    },
    {
        key: 'icon',
        dataIndex: 'icon',
        title: '图标',
        width: 60,
        align: "center",
        ellipsis: {showTitle: false},
        render: (value) => <IconFont type={value} />
    },
    {
        key: 'last',
        dataIndex: 'last',
        title: '菜单级别',
        width: 100,
        align: "center",
        render: value => value? <Tag color={"#334026"}>子菜单</Tag> : <Tag color={"#871274"}>父菜单</Tag>,
    },
    {
        key: 'disabled',
        dataIndex: 'disabled',
        title: '状态',
        width: 60,
        align: "center",
        render: value => value? <Tag color={"#c13c3c"}>禁用</Tag> : <Tag color={"#076e07"}>启用</Tag>,
    },
    {
        key: 'menuOrder',
        dataIndex: 'menuOrder',
        title: '菜单排序',
        width: 100,
        align: "center"
    },
    columnOrder,
    columnRemark,
    {
        key: "options",
        title: "操作",
        dataIndex: "options",
        align: "center",
        width: 130,
        fixed: "right",
        render: (_, record, __) => {
            return <Space size={15}>
                <Link key={"menu-details"} to={"details"} state={record}>详情</Link>
                <Link key={"menu-update"} to={"update"} state={record}>更新</Link>
                <Link key={"menu-delete"} style={{color: "#c13c3c"}} to={"delete"} state={record}>删除</Link>
            </Space>;
        }
    }
];


export default menuColumns;